<?php /* Smarty version 2.6.12, created on 2011-07-23 01:18:17
         compiled from search_detail.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'count', 'search_detail.html', 11, false),)), $this); ?>
<?php echo $this->_tpl_vars['xajax_scripts']; ?>

<form method='post' onsubmit='return check_form_pass();'>
<input type='hidden' name='op' id='op' value='detail_save'>
<div class='form_title'><?php echo @MI_ANALYZE_RESULT; ?>
</div>
<table align=center cellspacing='0' cellpadding='0' border='0'><tr><td>
<table align=center class='analysis_content' cellspacing='1' cellpadding='1' border='0'>
<tr>
<td colspan=5>
<table border=0 class='analysis_header'>
<tr>
<td colspan=<?php echo count($this->_tpl_vars['serology_match_info']); ?>
><?php echo @MI_POSITIVE_WELL; ?>
: <font color=red><?php echo $this->_tpl_vars['display_primer_numbers']; ?>
</font></td>
</tr>
<tr>
<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
<td><b>HLA-<?php echo $this->_tpl_vars['serology_id']; ?>
 <?php echo @MI_LOCUS; ?>
: <font color= '#2c8abc'><?php echo $this->_tpl_vars['info']['match_count']; ?>
</font></b></td>
<?php endforeach; endif; unset($_from); ?>
</tr>
<tr id='imperfect_counts' style='display:none;'>
<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
<td style='border: 1px dotted #ccccff;'><b><?php echo @MI_IMPERFECT_WELL; ?>
 HLA-<?php echo $this->_tpl_vars['serology_id']; ?>
 <?php echo @MI_IMPERFECT_WELL2; ?>
: <font color= '#2c8abc'><?php echo $this->_tpl_vars['info']['imperfect_count']; ?>
</font></b></td>
<?php endforeach; endif; unset($_from); ?>
</tr>
<tr id='rare_counts' style='display: none'>
<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
<td style='border: 1px dotted #ccccff;'><b><?php echo @MI_RARE_ITEMS; ?>
 HLA-<?php echo $this->_tpl_vars['serology_id']; ?>
 <?php echo @MI_RARE_ITEMS2; ?>
: <font color= '#2c8abc'><?php echo $this->_tpl_vars['info']['rare_count']; ?>
</font></b></td>
<?php endforeach; endif; unset($_from); ?>
</tr>
</table>
<?php if ($this->_tpl_vars['speed_serotypes'] == true): ?><input type='button' class='colorbutton' style="height: 25px;" value='&nbsp;<?php echo @MI_PREPARE_ALL_ITEMS; ?>
' onclick='location.href="/search.php?op=detail&sample_id=<?php echo $this->_tpl_vars['sample_id']; ?>
&full_serotypes=Y";'>&nbsp;<?php else:  if ($this->_tpl_vars['has_rare'] == true): ?><input type='button' id="MI_DISPLAY_RARE_ITEMS" class='colorbutton-red' style="height: 25px;" value="<?php echo @MI_DISPLAY_RARE_ITEMS; ?>
&nbsp;" onclick='display_rare(this);' /><input type='button' id="MI_HIDE_RARE_ITEMS" class='colorbutton-red' style="height: 25px; display: none;" value="<?php echo @MI_HIDE_RARE_ITEMS; ?>
&nbsp;" onclick='display_rare(this);' />&nbsp;<?php endif; ?>
<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
<?php if ($this->_tpl_vars['info']['match_count'] > 0 || $this->_tpl_vars['info']['imperfect_count'] > 0): ?>
<input type='button' class='colorbutton' style="height: 25px;" value='<?php echo @MI_DISPLAY_IMPERFECT_ITEMS; ?>
: <?php echo $this->_tpl_vars['serology_id']; ?>
' onclick='display_imperfect_<?php echo $this->_tpl_vars['serology_id']; ?>
(this);'>
<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
<?php endif; ?>
</td>
</tr>
<tr>
<td>&nbsp;<script>
function display_types_detail(pno)
{
    document.getElementById('line'+pno+'_serotype1').rows = 3;
    document.getElementById('line'+pno+'_serotype2').rows = 3;
    document.getElementById('line'+pno+'_genotypes').rows = 3;
//    document.getElementById('line'+pno+'_detail').style.display = '';
}
function hide_types_detail(pno)
{
    document.getElementById('line'+pno+'_serotype1').rows = 1;
    document.getElementById('line'+pno+'_serotype2').rows = 1;
    document.getElementById('line'+pno+'_genotypes').rows = 1;
//    document.getElementById('line'+pno+'_detail').style.display = 'none';
}
</script></td>
<th><?php echo @MI_SEROTYPE_1; ?>
</th>
<th><?php echo @MI_SEROTYPE_2; ?>
</th>
<th><?php echo @MI_GENOTYPES; ?>
</th>
<th><?php echo @MI_CHOOSES; ?>
</th>
</tr>
<?php $_from = $this->_tpl_vars['matchs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['match']):
?>
<?php $_from = $this->_tpl_vars['match']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?>
<tr style='display: none;'><td>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serology_id' value='<?php echo $this->_tpl_vars['line']['serology_id']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_line_no1' value='<?php echo $this->_tpl_vars['line']['line_no1']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_line_no2' value='<?php echo $this->_tpl_vars['line']['line_no2']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_primer_numbers' value='<?php echo $this->_tpl_vars['line']['match_save_primer_numbers']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_frequency' value='<?php echo $this->_tpl_vars['line']['frequency']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_imperfect' value='<?php echo $this->_tpl_vars['line']['imperfect']; ?>
'>
<input type='hidden' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_rare' value='<?php echo $this->_tpl_vars['line']['rare']; ?>
'>
</td></tr>
<?php if ($this->_tpl_vars['line']['imperfect'] == 'Y'): ?>
<?php if ($this->_tpl_vars['line']['selected'] != 'Y'): ?>
<tr id='line_<?php echo $this->_tpl_vars['line']['pno']; ?>
' class='imperfect_line' style='display: none;'>
<?php else: ?>
<tr id='line_<?php echo $this->_tpl_vars['line']['pno']; ?>
' class='imperfect_line'>
<?php endif; ?>
<td style='padding-top: 4px; text-align: left;'><b><?php echo $this->_tpl_vars['line']['match_numbers']; ?>
</b></td>
<td><textarea class='imperfect_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype1']; ?>
</textarea></td>
<td><textarea class='imperfect_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype2']; ?>
</textarea></td>
<td><textarea class='imperfect_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=70 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['genotypes']; ?>
</textarea>
<div id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_detail' style='background-color:blue;color:white;text-align:left;display:none;'>Line: <?php echo $this->_tpl_vars['line']['line_no1']; ?>
,<?php echo $this->_tpl_vars['line']['line_no2']; ?>
 / Frequency: <?php echo $this->_tpl_vars['line']['frequency']; ?>
</div></td>
<td><?php if ($this->_tpl_vars['can_edit']): ?><input type='checkbox' class='checkbox' class='imperfect_field' style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked' value='true'<?php if ($this->_tpl_vars['line']['selected'] == 'Y'): ?> checked<?php endif; ?>><?php else:  if ($this->_tpl_vars['line']['selected'] == 'Y'):  echo @_SELECTED;  endif;  endif; ?></td>
</tr>
<?php elseif ($this->_tpl_vars['line']['rare'] == 'Y'): ?>
<?php if ($this->_tpl_vars['line']['selected'] != 'Y'): ?>
<tr id='line_<?php echo $this->_tpl_vars['line']['pno']; ?>
' class='rare_line' style='display: none;'>
<?php else: ?>
<tr id='line_<?php echo $this->_tpl_vars['line']['pno']; ?>
' class='rare_line'>
<?php endif; ?>
<td style='padding-top: 4px; text-align: left;'><b><?php echo $this->_tpl_vars['line']['match_numbers']; ?>
</b></td>
<td><textarea class='rare_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype1']; ?>
</textarea></td>
<td><textarea class='rare_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype2']; ?>
</textarea></td>
<td><textarea class='rare_field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=70 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['genotypes']; ?>
</textarea>
<div id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_detail' style='background-color:blue;color:white;text-align:left;display:none;'>Line: <?php echo $this->_tpl_vars['line']['line_no1']; ?>
,<?php echo $this->_tpl_vars['line']['line_no2']; ?>
 / Frequency: <?php echo $this->_tpl_vars['line']['frequency']; ?>
</div></td>
<td><?php if ($this->_tpl_vars['can_edit']): ?><input type='checkbox' class='checkbox' class='rare_field' style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked' value='true'<?php if ($this->_tpl_vars['line']['selected'] == 'Y'): ?> checked<?php endif; ?>><?php else:  if ($this->_tpl_vars['line']['selected'] == 'Y'):  echo @_SELECTED;  endif;  endif; ?></td>
</tr>
<?php else: ?>
<tr id='line_<?php echo $this->_tpl_vars['line']['pno']; ?>
'>
<td>&nbsp;</td>
<td><textarea class='field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype1' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype1']; ?>
</textarea></td>
<td><textarea class='field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=14 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_serotype2' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['serotype2']; ?>
</textarea></td>
<td><textarea class='field' readonly style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' cols=70 rows=1 id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_genotypes' onfocus='display_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);' onblur='hide_types_detail(<?php echo $this->_tpl_vars['line']['pno']; ?>
);'><?php echo $this->_tpl_vars['line']['genotypes']; ?>
</textarea>
<div id='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_detail' style='background-color:blue;color:white;text-align:left;display:none;'>Line: <?php echo $this->_tpl_vars['line']['line_no1']; ?>
,<?php echo $this->_tpl_vars['line']['line_no2']; ?>
 / Frequency: <?php echo $this->_tpl_vars['line']['frequency']; ?>
</div></td>
<td><?php if ($this->_tpl_vars['can_edit']): ?><input type='checkbox' class='checkbox' class='field' style='background-color:<?php echo $this->_tpl_vars['line']['view_color']; ?>
;' name='line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked' value='true'<?php if ($this->_tpl_vars['line']['selected'] == 'Y'): ?> checked<?php endif; ?>><?php else:  if ($this->_tpl_vars['line']['selected'] == 'Y'):  echo @_SELECTED;  endif;  endif; ?></td>
</tr>
<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
<?php endforeach; endif; unset($_from); ?>
<td colspan=4 style='text-align:right;'><b><?php if ($this->_tpl_vars['final'] == 'Y'):  echo @MI_IS_FINAL;  else:  echo @MI_IS_UNFINISHED;  endif; ?></b>
<input type='hidden' name='save_primer_numbers' value='<?php echo $this->_tpl_vars['save_primer_numbers']; ?>
'></td>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" valign="middle"><?php if ('N' == 'N'): ?>
      <input type='button' class='btn_print' onClick='location.href="/sample_output.php?sample_id=<?php echo $this->_tpl_vars['sample_id']; ?>
";' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_PRINT; ?>
&nbsp;" />
      <?php endif; ?> <?php if ($this->_tpl_vars['can_edit']): ?> <input type='submit' class='btn_save' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_SAVE; ?>
" />
      <?php endif; ?> <?php if ($this->_tpl_vars['final'] = 'Y'): ?> <input type='button' class="btn_del" onClick='if (confirm("<?php echo @MI_SAMPLE_DELETE_CONFIRM; ?>
")) { document.getElementById("op").value="detail_delete"; this.form.submit(); }' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_DELETE; ?>
&nbsp;" />
      <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['search_uri'] )): ?> <input type='button' class='btn_backsearch' onClick='location.href="<?php echo $this->_tpl_vars['search_uri']; ?>
"' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_BACK_SEARCH; ?>
" />
      <?php else: ?> <input type='button' class='btn_uppage' onClick='history.go(-1);' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_BACK; ?>
" />
      <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['prior_sample_id'] )): ?> <input type='button' class='btn_backward' onClick='location.href="/search.php?op=detail&sample_id=<?php echo $this->_tpl_vars['prior_sample_id']; ?>
";' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_PRIOR_SAMPLE; ?>
&nbsp;" />
      <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['next_sample_id'] )): ?> <input type='button' class='btn_forward' onClick='location.href="/search.php?op=detail&sample_id=<?php echo $this->_tpl_vars['next_sample_id']; ?>
";' value="&nbsp;<?php echo @MI_NEXT_SAMPLE; ?>
&nbsp;" />
      <?php endif; ?>
    </td>
  </tr>
</table><br />
        <table width="50%" border='1' align="center" cellpadding='1' cellspacing='1' bordercolor="157fb9" class='form_detail'>
          <script>

var PatientIDVerified = true;

function checkIsValidDate(str)
{
  if (str == "")
     return true;
  var pattern = /^(\d{4})\-(\d{1,2})\-(\d{1,2})$/g;
  if(!pattern.test(str))
     return false;
  var arrDate = str.split("-");
  if(parseInt(arrDate[0],10) < 100)
     arrDate[0] = 2000 + parseInt(arrDate[0],10) + "";
  var date = new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]);
  if(date.getYear() == arrDate[0]
     && date.getMonth() == (parseInt(arrDate[1],10)-1)+""
     && date.getDate() == arrDate[2])
     return true;
  else
     return false;
}

function set_lot_no_value(lot_no)
{
    var obj = document.getElementById("lot_no");

    if (lot_no == '')
        obj.selectedIndex = 0;
    else if (obj != null)
    {
        try
        {
            obj.selectedIndex = 0;
            for (var i=0; i<obj.options.length; i++)
                if (obj.options[i].innerText.match(lot_no+" "))
                {
                    obj.selectedIndex = i;
                    break;
                }
        }
        catch (e)
        {
        }
    }
}

function clear_patient(clear_patient_id)
{
    PatientIDVerified = false;

    document.getElementById("patient_rowguid").value = 'false';

    if (clear_patient_id == true)
    {
        document.getElementById("institution").value = '<?php echo $this->_tpl_vars['institution']; ?>
';
        document.getElementById("patient_id").value = '';
    }

    document.getElementById("ethnic").value = '';
    document.getElementById("first_name").value = '';
    document.getElementById("last_name").value = '';
    document.getElementById("sex_M").checked = false;
    document.getElementById("sex_F").checked = false;
    document.getElementById("age").value = '';

    document.getElementById("patient_exists_hint").style.display = 'none';
    document.getElementById("patient_not_exists_hint").style.display = 'none';
}

function show_patient_not_exists()
{
    clear_patient();

    document.getElementById("patient_not_exists_hint").style.display = '';
}

function show_patient_exists(rowguid,institution,patient_id,ethnic,first_name,last_name,sex,age)
{
    document.getElementById("patient_rowguid").value = rowguid;

    if (document.getElementById("institution").value != institution)
        document.getElementById("institution").value = institution;

    if (document.getElementById("patient_id").value != patient_id)
        document.getElementById("patient_id").value = patient_id;

    document.getElementById("patient_not_exists_hint").style.display = 'none';
    document.getElementById("patient_exists_hint").style.display = '';

    document.getElementById("ethnic").value = ethnic;
    document.getElementById("first_name").value = first_name;
    document.getElementById("last_name").value = last_name;

    document.getElementById("sex_M").checked = false;
    document.getElementById("sex_F").checked = false;

    if (sex == 'M')
        document.getElementById("sex_M").checked = true;
    else if (sex == 'F')
        document.getElementById("sex_F").checked = true;

    document.getElementById("age").value = age>0?age:'';
}

function do_add_lot(auto_focus)
{
    new_lot_no = document.getElementById("custom_add_lot_no").value;
    new_lot_expires = document.getElementById("custom_add_lot_expires").value;
    new_lot_expires = new_lot_expires.replace(/\//g, "-");

    if (new_lot_no == '' || new_lot_expires == '')
    {
        alert('<?php echo @MI_REQUIRE_LOT_DATA; ?>
');
        return false;
    }

    if (!checkIsValidDate(new_lot_expires))
    {
        alert('<?php echo @MI_INVALID_DATETIME_FORMAT; ?>
');
        return false;
    }

    for (var i=0; i<document.getElementById('lot_no').options.length; i++)
        if (document.getElementById('lot_no').options[i].innerText.replace(/\s-\s.*/, "") == new_lot_no)
        {
            document.getElementById('lot_no').selectedIndex = i;
            hide_add_lot(auto_focus);
            return true;
        }

    var objOption = new Option(new_lot_no + ' / <?php echo @MI_KIT_LOT_EXPIRES; ?>
 ' + new_lot_expires);
    document.getElementById('lot_no').options.add(objOption, 1);

    document.getElementById('lot_no').selectedIndex = 1;
    hide_add_lot(auto_focus);

    return true;
}

function show_add_lot(auto_focus)
{
    document.getElementById("custom_add_lot_no").value = '';
    document.getElementById("custom_add_lot_expires").value = '';
    document.getElementById("list_lot_block").style.display = 'none';
    document.getElementById("add_lot_block").style.display = '';
    if (auto_focus == true)
        document.getElementById("custom_add_lot_no").focus();
}

function hide_add_lot(auto_focus)
{
    document.getElementById("add_lot_block").style.display = 'none';
    document.getElementById("list_lot_block").style.display = '';
    if (auto_focus == true)
        document.getElementById('lot_no').focus();
}

var LastCheckInstitution = '';
var LastCheckPatientId = '';

function ServerSync_GetPatientInfo()
{
    var institution = document.getElementById("institution").value;

    if (institution == '')
        institution = 'EMPTY';

    var patient_id = document.getElementById("patient_id").value;

    if (LastCheckInstitution != institution || LastCheckPatientId != patient_id)
    {
        LastCheckInstitution = institution;
        LastCheckPatientId = patient_id;
        if (patient_id != '')
            xajax_Ajax_GetPatientInfo(institution, patient_id);
        else
            PatientIDVerified = true;
    }
}

function check_form_pass()
{
<?php if (! $this->_tpl_vars['can_edit']): ?>
    return false;
<?php endif; ?>

    if (document.getElementById("op").value == 'detail_delete')
    {
        if (comfirm('<?php echo @MI_SAMPLE_DELETE_CONFIRM; ?>
'))
            return true;
        else
            return false;
    }

    if (document.getElementById('institution').value == '')
        document.getElementById('institution').value = 'EMPTY';

    if (document.getElementById("add_lot_block").style.display == '')
    {
        if (document.getElementById("custom_add_lot_no").value != '')
        {
            if (!do_add_lot())
                return false;
        }
        else
            hide_add_lot();
    }

    if (
        document.getElementById('patient_id').value != '' ||
        document.getElementById('ethnic').value != '' ||
        document.getElementById('first_name').value != '' ||
        document.getElementById('last_name').value != '' ||
        document.getElementById("sex_M").checked ||
        document.getElementById("sex_F").checked ||
        document.getElementById('age').value != '')
    {
        if (document.getElementById('institution').value == '' ||
            document.getElementById('patient_id').value == '' ||
            document.getElementById('first_name').value == '' ||
            document.getElementById('last_name').value == '')
        {
            alert('<?php echo @MI_ERROR_REQUIRE_PATIENT_INFO; ?>
');
            if (document.getElementById('institution').value == '')
                document.getElementById('institution').focus();
            else if (document.getElementById('patient_id').value == '')
                document.getElementById('patient_id').focus();
            else if (document.getElementById('first_name').value == '')
                document.getElementById('first_name').focus();
            else if (document.getElementById('last_name').value == '')
                document.getElementById('last_name').focus();
            return false;
        }
    }

    if (!PatientIDVerified)
    {
        ServerSync_GetPatientInfo();
        return false;
    }

    var HasChecked;

    if (document.getElementById('final').checked)
    {
<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
        HasChecked = false;
        for (var i=0; i<<?php echo $this->_tpl_vars['matchs_max_pno']; ?>
; i++)
            if (document.getElementById('line'+i+'_serology_id').value == '<?php echo $this->_tpl_vars['serology_id']; ?>
' &&
                document.getElementById('line'+i+'_checked').checked)
            {
                if (HasChecked == true)
                {
                    alert('<?php echo @MI_ERROR_REQUIRE_ONE_SEROLOGY; ?>
');
                    return false;
                }
                HasChecked = true;
            }
        if (!HasChecked)
        {
            alert('<?php echo @MI_ERROR_REQUIRE_ONE_SEROLOGY; ?>
');
            return false;
        }

<?php endforeach; endif; unset($_from); ?>
    }

    return true;
}

</script>
          <?php if (! $this->_tpl_vars['can_edit']): ?>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_SAMPLE_ID; ?>
</th>
            <td><?php echo $this->_tpl_vars['sample_id']; ?>

              <input type='hidden' name='sample_id' value=''></td>
            <th><?php echo @MI_SELECT_KIT_ID; ?>
</th>
            <td><?php echo $this->_tpl_vars['kit_id']; ?>
</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_DNA_EXT_METHOD; ?>
</th>
            <td><?php echo $this->_tpl_vars['dna_ext_method']; ?>
&nbsp;</td>
            <th><?php echo @MI_DNA_OD; ?>
</th>
            <td><?php echo $this->_tpl_vars['dna_od']; ?>
&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_KIT_LOT_NO; ?>
</th>
            <td colspan=3><?php $_from = $this->_tpl_vars['lot_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?> <?php if ($this->_tpl_vars['lot_no'] == $this->_tpl_vars['line']['lot_no']):  echo $this->_tpl_vars['line']['lot_no']; ?>

              / <?php echo @MI_KIT_LOT_EXPIRES; ?>
 <?php echo $this->_tpl_vars['line']['lot_expires'];  endif; ?>
              <?php endforeach; endif; unset($_from); ?>&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_TEST_BY; ?>
</th>
            <td><?php echo $this->_tpl_vars['test_by']; ?>
&nbsp;</td>
            <th><?php echo @MI_TEST_DATE; ?>
</th>
            <td><?php echo $this->_tpl_vars['test_date']; ?>
&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_COMMENT; ?>
</th>
            <td colspan=3><?php echo $this->_tpl_vars['comment']; ?>
&nbsp;</td>
          </tr>
          <?php if ($this->_tpl_vars['patient_rowguid'] !== false): ?>
          <tr bordercolor="#cbe5f6" style='display:none;'>
            <th><?php echo @MI_INSTITUTION; ?>
</th>
            <td colspan=3><?php echo $this->_tpl_vars['institution']; ?>
&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_PATIENT_ID; ?>
</th>
            <td><?php echo $this->_tpl_vars['patient_id']; ?>
&nbsp;</td>
            <th><?php echo @MI_ETHNIC; ?>
</th>
            <td><?php echo $this->_tpl_vars['ethnic']; ?>
&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_FIRST_NAME; ?>
</th>
            <td><?php echo $this->_tpl_vars['first_name']; ?>
&nbsp;</td>
            <th><?php echo @MI_LAST_NAME; ?>
</th>
            <td><?php echo $this->_tpl_vars['last_name']; ?>
&nbsp;</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_SEX; ?>
</th>
            <td><?php if ($this->_tpl_vars['sex'] == 'M'):  echo @_MALE;  endif;  if ($this->_tpl_vars['sex'] == 'F'):  echo @_FEMALE;  endif; ?>&nbsp;</td>
            <th><?php echo @MI_AGE; ?>
</th>
            <td><?php echo $this->_tpl_vars['age']; ?>
&nbsp;</td>
          </tr>
          <?php endif; ?> <?php else: ?>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_SAMPLE_ID; ?>
</th>
            <td><?php echo $this->_tpl_vars['sample_id']; ?>

              <input type='hidden' name='sample_id' value='<?php echo $this->_tpl_vars['sample_id']; ?>
'></td>
            <th><?php echo @MI_SELECT_KIT_ID; ?>
</th>
            <td><?php echo $this->_tpl_vars['kit_id']; ?>

              <input type='hidden' name='kit_id' value='<?php echo $this->_tpl_vars['kit_id']; ?>
'></td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_DNA_EXT_METHOD; ?>
</th>
            <td>
              <input size=20 maxlength=30 name='dna_ext_method' value='<?php echo $this->_tpl_vars['dna_ext_method']; ?>
'></td>
            <th><?php echo @MI_DNA_OD; ?>
</th>
            <td>
              <input size=20 maxlength=12 name='dna_od' value='<?php echo $this->_tpl_vars['dna_od']; ?>
'></td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_KIT_LOT_NO; ?>
</th>
            <td colspan=3><div id='list_lot_block'<?php if (count ( $this->_tpl_vars['lot_list'] ) == 0): ?>
              style='display:none;'<?php endif; ?>>
              <select name='lot_no'>
                <option></option><?php $_from = $this->_tpl_vars['lot_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?>
                <option<?php if ($this->_tpl_vars['lot_no'] == $this->_tpl_vars['line']['lot_no']): ?> selected<?php endif; ?>><?php echo $this->_tpl_vars['line']['lot_no']; ?>
 / <?php echo @MI_KIT_LOT_EXPIRES; ?>
 <?php echo $this->_tpl_vars['line']['lot_expires']; ?>
</option> <?php endforeach; endif; unset($_from); ?>
              </select>
              <input type='button' class='sbutton' value="&nbsp;<?php echo @MI_ADD_LOT; ?>
&nbsp;" onclick='show_add_lot(true);'></div> <div id='add_lot_block'
              <?php if (count ( $this->_tpl_vars['lot_list'] ) > 0): ?> style='display:none;'<?php endif; ?>>
              <input size=20 maxlength=200 name='custom_add_lot_no' value=''>
              &nbsp;<?php echo @MI_KIT_LOT_EXPIRES; ?>

              <input size=10 maxlength=10 name='custom_add_lot_expires' value=''>
              &nbsp; <input type='button' class='sbutton' value="&nbsp;<?php echo @_ADD; ?>
&nbsp;" onclick='do_add_lot(true);'>
              <input type='button' class='sbutton' value="&nbsp;<?php echo @_CANCEL; ?>
&nbsp;" onclick='hide_add_lot(true);'></div>
            </td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_TEST_BY; ?>
</th>
            <td><?php echo $this->_tpl_vars['test_by']; ?>
</td>
            <th><?php echo @MI_TEST_DATE; ?>
</th>
            <td><?php echo $this->_tpl_vars['test_date']; ?>
</td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <td nowrap background="<?php echo $this->_tpl_vars['theme_url']; ?>
/images/form_detail_pic02.jpg" style="color: black; font-size: 8pt; text-align: right; font-weight: bold;"><?php echo @MI_COMMENT; ?>
</td>
            <td colspan=3>
              <textarea name='comment' class='textarea' cols=70 rows=5><?php echo $this->_tpl_vars['comment']; ?>
</textarea></td>
          </tr>
          <tr bordercolor="#cbe5f6" style='display:none;'>
            <th><?php echo @MI_INSTITUTION; ?>
</th>
            <td colspan=3>
              <input size=70 maxlength=120 name='institution' value='<?php echo $this->_tpl_vars['institution']; ?>
'></td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <td nowrap background="<?php echo $this->_tpl_vars['theme_url']; ?>
/images/form_detail_pic03.jpg" style="color: black; font-size: 8pt; text-align: right; font-weight: bold;"><?php echo @MI_PATIENT_ID; ?>
</td>
            <td>
              <input size=20 maxlength=20 name='patient_id' value='<?php echo $this->_tpl_vars['patient_id']; ?>
' onfocus='clear_patient();' onkeypress='clear_patient();' onblur='ServerSync_GetPatientInfo();'>
              <input type='hidden' name='patient_rowguid' value='false'> <div id='patient_exists_hint' style='display:none;'>
                <font class='field_hint'><b><?php echo @MI_PATIENT_EXISTS; ?>
</b></font></div>
              <div id='patient_not_exists_hint' style='display:none;'> <font class='field_hint'><b><?php echo @MI_PATIENT_NOT_EXISTS; ?>
</b></font></div></td>
            <td nowrap background="<?php echo $this->_tpl_vars['theme_url']; ?>
/images/form_detail_pic03.jpg" style="color: black; font-size: 8pt; text-align: right; font-weight: bold;"><?php echo @MI_ETHNIC; ?>
</td>
            <td>
              <input size=20 maxlength=20 name='ethnic' value=''></td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_FIRST_NAME; ?>
</th>
            <td>
              <input size=20 maxlength=50 name='first_name' value=''></td>
            <th><?php echo @MI_LAST_NAME; ?>
</th>
            <td>
              <input size=20 maxlength=50 name='last_name' value=''></td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_SEX; ?>
</th>
            <td>
              <input type='radio' id='sex_M' name='sex' value='M'>
              <?php echo @_MALE; ?>
 &nbsp; <input type='radio' id='sex_F' name='sex' value='F'>
              <?php echo @_FEMALE; ?>
</td>
            <th><?php echo @MI_AGE; ?>
</th>
            <td>
              <input size=20 maxlength=3 name='age' value=''></td>
          </tr>
          <?php if ($this->_tpl_vars['final'] != 'Y'): ?>
          <tr bordercolor="#cbe5f6">
            <th><?php echo @MI_FINAL; ?>
</th>
            <td colspan=3>
              <input type='checkbox' class='checkbox' name='final' value='true' checked>
          </tr>
          <?php endif; ?> <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['sample_images'] )): ?>
          <tr bordercolor="#cbe5f6" id='sample_image_btns' style='display:none;'>
            <td></td>
            <td colspan=3 align=left valign=top nowrap>
              <input type='hidden' name='img_rotate' value='<?php echo $this->_tpl_vars['img_rotate']; ?>
'>
              <input type='hidden' name='img_zoom' value='<?php echo $this->_tpl_vars['img_zoom']; ?>
'> <script>
var InitSample = false;

var SampleImageWidth = 0;
var SampleImageHeight = 0;

function InitSampleImage()
{
    try
    {
        InitSample = true;

        SampleImageWidth = document.getElementById("<?php echo $this->_tpl_vars['sample_images']['0']['id']; ?>
").width;
        SampleImageHeight = document.getElementById("<?php echo $this->_tpl_vars['sample_images']['0']['id']; ?>
").height;

        RotationVal = 1*document.getElementById('img_rotate').value;
        RotationVal = RotationVal % 4;
        document.getElementById('img_rotate').value = RotationVal;

        ZoomVal = Math.round(1*document.getElementById('img_zoom').value)/10;
        if (document.getElementById("<?php echo $this->_tpl_vars['sample_images']['0']['id']; ?>
").width * ZoomVal < 200 ||
                document.getElementById("<?php echo $this->_tpl_vars['sample_images']['0']['id']; ?>
").width * ZoomVal > 1024)
            ZoomVal = 1;
        document.getElementById('img_zoom').value = Math.floor(ZoomVal*10);

<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>

        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.filter="progid:DXImageTransform.Microsoft.BasicImage(Rotation=" + RotationVal + ");";
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width = SampleImageWidth * ZoomVal;
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height = SampleImageHeight * ZoomVal;
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.width = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width+4;
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.height = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height+4;
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.display="";

<?php endforeach; endif; unset($_from); ?>

        document.getElementById("sample_image_btns").style.display="";
    }
    catch (e)
    {
        location.reload();
    }
}
function ShowSampleImage()
{
    if (!InitSample)
        InitSampleImage();
    else
    {
<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>
        document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.display="";
<?php endforeach; endif; unset($_from); ?>
        document.getElementById("show_image_btns").style.display="none";
        document.getElementById("sample_image_btns").style.display="";
    }
}
function HideSampleImage()
{
    document.getElementById("show_image_btns").style.display="";
    document.getElementById("sample_image_btns").style.display="none";
<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.display="none";
<?php endforeach; endif; unset($_from); ?>
}
function DoSmapleImageRotation(val)
{
    RotationVal = 1*document.getElementById('img_rotate').value;
    if (val < 0)
        val = 4+val;
    RotationVal = (RotationVal + val) % 4;
    document.getElementById('img_rotate').value = RotationVal;

<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.filter="progid:DXImageTransform.Microsoft.BasicImage(Rotation=" + RotationVal + ");";
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.width = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width+4;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.height = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height+4;
<?php endforeach; endif; unset($_from); ?>
}
function DoSmapleImageZoom(val)
{
    ZoomVal = Math.round(1*document.getElementById('img_zoom').value)/10 + val;
    if (SampleImageWidth * ZoomVal < 200)
        ZoomVal = 200/SampleImageWidth;
    else if (SampleImageWidth * ZoomVal > 1000)
        ZoomVal = 1000/SampleImageWidth;
    document.getElementById('img_zoom').value = Math.floor(ZoomVal*10);

<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width = SampleImageWidth * ZoomVal;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height = SampleImageHeight * ZoomVal;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.width = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width+4;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.height = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height+4;
<?php endforeach; endif; unset($_from); ?>
}
function ResetSampleImage()
{
    document.getElementById('img_zoom').value = 1;
    document.getElementById('img_rotate').value = 0;

<?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?>
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width = SampleImageWidth;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height = SampleImageHeight;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.filter="progid:DXImageTransform.Microsoft.BasicImage(Rotation=0);";
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.width = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").width+4;
    document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div").style.height = document.getElementById("<?php echo $this->_tpl_vars['sample_img']['id']; ?>
").height+4;
<?php endforeach; endif; unset($_from); ?>
}
</script> <input type='button' class='minibutton' value="&nbsp;<?php echo @MI_SAMPLE_IMAGE_LEFT_ROTATE; ?>
&nbsp;" onclick='DoSmapleImageRotation(-1);'>
              <input type='button' class='minibutton' value="&nbsp;<?php echo @MI_SAMPLE_IMAGE_ZOOM_IN; ?>
&nbsp;" onclick='DoSmapleImageZoom(0.2);'>
              <input type='button' class='minibutton' value="&nbsp;<?php echo @MI_SAMPLE_IMAGE_ZOME_OUT; ?>
&nbsp;" onclick='DoSmapleImageZoom(-0.2);'>
              <input type='button' class='minibutton' value="&nbsp;<?php echo @MI_SAMPLE_IMAGE_RIGHT_ROTATE; ?>
&nbsp;" onclick='DoSmapleImageRotation(1);'>
              <input type='button' class='minibutton' value="&nbsp;<?php echo @MI_SAMPLE_IMAGE_RESET; ?>
&nbsp;" onclick='ResetSampleImage();'>
              <input type='button' class='minibutton' value="&nbsp;<?php echo @_HIDE; ?>
&nbsp;" onclick='HideSampleImage();'>
            </td>
          </tr>
          <tr bordercolor="#cbe5f6">
            <td></td>
            <td colspan=3 align=left valign=center>
              <div id='show_image_btns'>
                <input type='button' class='sbutton' value="&nbsp;<?php echo @MI_SHOW_SAMPLE_IMAGE; ?>
&nbsp;" onclick='ShowSampleImage();'>
              </div>
              <?php $_from = $this->_tpl_vars['sample_images']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['sample_img']):
?> <div id='<?php echo $this->_tpl_vars['sample_img']['id']; ?>
_div' style='filter:progid:DXImageTransform.Microsoft.BasicImage(0);'><img id='<?php echo $this->_tpl_vars['sample_img']['id']; ?>
' style='border: 2px dotted #8080ff;' onload='ShowSampleImage();HideSampleImage();' src='<?php echo $this->_tpl_vars['sample_img']['src']; ?>
'></div>
              <br/> <?php endforeach; endif; unset($_from); ?> </td>
          </tr>
          <?php endif; ?>
          <script>
<?php if ($this->_tpl_vars['has_rare'] == true): ?>
    function display_rare(obj)
    {
        display_items = obj.value.indexOf("<?php echo @MI_DISPLAY_RARE_ITEMS; ?>
") > -1;
        if (display_items)
            document.getElementById('rare_counts').style.display = '';
        else
            document.getElementById('rare_counts').style.display = 'none';
<?php $_from = $this->_tpl_vars['matchs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['match']):
?>
<?php $_from = $this->_tpl_vars['match']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?>
<?php if ($this->_tpl_vars['line']['rare'] == 'Y'): ?>
        if (display_items || (document.getElementById('line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked')!=null && document.getElementById('line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked').checked))
            document.getElementById('line_<?php echo $this->_tpl_vars['line']['pno']; ?>
').style.display = '';
        else
            document.getElementById('line_<?php echo $this->_tpl_vars['line']['pno']; ?>
').style.display = 'none';
<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
<?php endforeach; endif; unset($_from); ?>
        if (display_items) {
            document.all.MI_DISPLAY_RARE_ITEMS.style.display = "none";
            document.all.MI_HIDE_RARE_ITEMS.style.display = "";
            // obj.value = "<?php echo @MI_HIDE_RARE_ITEMS; ?>
";
        } else {
            document.all.MI_DISPLAY_RARE_ITEMS.style.display = "";
            document.all.MI_HIDE_RARE_ITEMS.style.display = "none";
            // obj.value = "<?php echo @MI_DISPLAY_RARE_ITEMS; ?>
";
        }
    }
<?php endif; ?>

<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
    var imperfect_counts_<?php echo $this->_tpl_vars['serology_id']; ?>
_display = false;
<?php endforeach; endif; unset($_from); ?>

    function display_imperfect_counts()
    {
        if (<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
imperfect_counts_<?php echo $this->_tpl_vars['serology_id']; ?>
_display || <?php endforeach; endif; unset($_from); ?> false)
            document.getElementById('imperfect_counts').style.display = '';
        else
            document.getElementById('imperfect_counts').style.display = 'none';
    }

<?php $_from = $this->_tpl_vars['serology_match_info']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['serology_id'] => $this->_tpl_vars['info']):
?>
    function display_imperfect_<?php echo $this->_tpl_vars['serology_id']; ?>
(obj)
    {
        display_items = obj.value.indexOf("<?php echo @MI_DISPLAY_IMPERFECT_ITEMS; ?>
: <?php echo $this->_tpl_vars['serology_id']; ?>
") > -1;
        imperfect_counts_<?php echo $this->_tpl_vars['serology_id']; ?>
_display = display_items;
        display_imperfect_counts();

<?php $_from = $this->_tpl_vars['matchs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['match']):
?>
<?php $_from = $this->_tpl_vars['match']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['line']):
?>
<?php if ($this->_tpl_vars['line']['imperfect'] == 'Y' && $this->_tpl_vars['line']['serology_id'] == $this->_tpl_vars['serology_id']): ?>
        if (display_items || (document.getElementById('line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked')!=null && document.getElementById('line<?php echo $this->_tpl_vars['line']['pno']; ?>
_checked').checked))
            document.getElementById('line_<?php echo $this->_tpl_vars['line']['pno']; ?>
').style.display = '';
        else
            document.getElementById('line_<?php echo $this->_tpl_vars['line']['pno']; ?>
').style.display = 'none';
<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
<?php endforeach; endif; unset($_from); ?>
        if (display_items)
            obj.value = "<?php echo @MI_HIDE_IMPERFECT_ITEMS; ?>
: <?php echo $this->_tpl_vars['serology_id']; ?>
";
        else
            obj.value = "<?php echo @MI_DISPLAY_IMPERFECT_ITEMS; ?>
: <?php echo $this->_tpl_vars['serology_id']; ?>
";
    }

<?php endforeach; endif; unset($_from); ?>
</script>
        </table>
        <br>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center" valign="middle"><?php if ($this->_tpl_vars['final'] == 'Y'): ?>
              <input type='button' class='btn_print' onClick='location.href="/sample_output.php?sample_id=<?php echo $this->_tpl_vars['sample_id']; ?>
";' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_PRINT; ?>
&nbsp;" />
              <?php endif; ?> <?php if ($this->_tpl_vars['can_edit']): ?> <input type='submit' class='btn_save' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_SAVE; ?>
" />
              <?php endif; ?> <?php if ($this->_tpl_vars['final'] != 'Y'): ?> <input type='button' class='btn_del' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_DELETE; ?>
&nbsp;" onclick='if (confirm("<?php echo @MI_SAMPLE_DELETE_CONFIRM; ?>
")) { document.getElementById("op").value="detail_delete"; this.form.submit(); }' />
              <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['search_uri'] )): ?> <input type='button' class='btn_backsearch' onClick='location.href="<?php echo $this->_tpl_vars['search_uri']; ?>
"' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_BACK_SEARCH; ?>
" />
              <?php else: ?> <input type='button' class='btn_uppage' onClick='history.go(-1);' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_BACK; ?>
" />
              <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['prior_sample_id'] )): ?> <input type='button' class='btn_backward' onClick='location.href="/search.php?op=detail&sample_id=<?php echo $this->_tpl_vars['prior_sample_id']; ?>
";' value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo @MI_PRIOR_SAMPLE; ?>
&nbsp;" />
              <?php endif; ?> <?php if (! empty ( $this->_tpl_vars['next_sample_id'] )): ?> <input type='button' class='btn_forward' onClick='location.href="/search.php?op=detail&sample_id=<?php echo $this->_tpl_vars['next_sample_id']; ?>
";' value="&nbsp;<?php echo @MI_NEXT_SAMPLE; ?>
" />
              <?php endif; ?> </td>
          </tr>
        </table></td></tr></table>
</form>
<script>
<?php if ($this->_tpl_vars['can_edit']): ?>
ServerSync_GetPatientInfo();
<?php endif; ?>
</script>